package com.beiding.workordersystem.common.utils;


import java.nio.ByteBuffer;

public class NumberUtils {

    public static byte[] longToByteArray(long l) {
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.putLong(0, l);
        return buffer.array();
    }

    public static long bytesToLong(byte[] bytes) {
        if (bytes.length != 8) {
            throw new RuntimeException("数组长度必须为8");
        }
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.put(bytes, 0, 8);
        buffer.flip();
        return buffer.getLong();
    }

}
